var t,
  e = require("../../@babel/runtime/helpers/toConsumableArray"),
  a = require("../../utils/http.js"),
  n = require("../../utils/api.js"),
  r = require("../../utils/language/switchLanguage.js");
Page({
  data: {
    is_show: !1,
    isShowQr: !1,
    isShowQrcode: 0,
    content: {},
    newOrderDetailInfoVOList: [],
    newOrderGropList: [],
  },
  onLoad: function (t) {
    this.initLanguage(),
      this.setData({
        orderNo: t.orderNo,
        merchantNo: wx.getStorageSync("merchantNo"),
      }),
      this.getOrderDetail({ orderSn: t.orderNo });
  },
  initLanguage: function () {
    var t = r.languageVersion(wx.getStorageSync("language"));
    this.setData({ _t: t, languageType: wx.getStorageSync("language") }),
      wx.setNavigationBarTitle({ title: t["订单信息"] });
  },
  getOrderDetail: function (r) {
    var o = this;
    a.getOrderDetail(r).then(function (a) {
      var r = a.data;
      o.setData({ content: r }),
        (t = setInterval(function () {
          var e = n.CountDown(a.data.createTime);
          0 == e && clearInterval(t), o.setData({ countDown: e });
        }, 1e3));
      var i = [],
        s = [];
      r.orderDetailInfoVOList &&
        r.orderDetailInfoVOList.map(function (t) {
          t.museumOrderUserVOS &&
            2 == t.ticketClassify &&
            s.push({ parenting: t.museumOrderUserVOS }),
            t.museumOrderUserVOS &&
              2 !== t.ticketClassify &&
              i.push.apply(i, e(t.museumOrderUserVOS));
        }),
        i.forEach(function (t) {}),
        o.setData({ newOrderDetailInfoVOList: i, newOrderGropList: s });
    });
  },
  subForm: n.throttle(function () {
    this.wechatPay();
  }),
  wechatPay: function (t) {
    var e = this,
      r = {
        merchantNo: wx.getStorageSync("merchantNo"),
        tradeType: "wxSmallPay",
        payType: 4,
        payConfigType: 4,
        orderNo: this.data.orderNo,
      },
      o = n.encryptBASE64(JSON.stringify(r)),
      i = { sign: n.autograph(o), signData: o };
    a.wechatPay(i).then(function (t) {
      requireMiniProgram()
        .requestPayment(t.data)
        .then(function (t) {
          "requestPayment:ok" == t.errMsg &&
            (wx.showLoading({ title: e.data._t["支付处理中"] + "..." }),
            setTimeout(function () {
              wx.hideLoading();
              var t = getCurrentPages(),
                e = t[t.length - 2];
              e.setData({ refresh: !0 }, function () {
                var t = e.data.params;
                (t.page = 1), e.getOrderList(t);
              }),
                wx.navigateBack();
            }, 1e3));
        })
        .catch(function (t) {
          "requestPayment:fail cancel" != t.errMsg &&
            "requestPayment:fail" != t.errMsg &&
            wx.showModal({
              title: e.data._t["通知"],
              showCancel: !1,
              content: e.data._t["调起支付失败，请稍后重试"] + "...",
              confirmText: e.data._t["确认"],
            });
        });
    });
  },
  CancelOrder: function (t) {
    var e = t.currentTarget.dataset.orderno,
      r = this;
    wx.showModal({
      title: r.data._t["提示"],
      content: r.data._t["是否确认取消？"],
      confirmText: r.data._t["确定"],
      cancelText: r.data._t["取消"],
      success: function (t) {
        if (t.confirm) {
          var o = { merchantNo: r.data.merchantNo, orderSn: e };
          wx.showLoading({ title: r.data._t["取消"] + "..." }),
            setTimeout(function () {
              wx.hideLoading();
            }, 1e3),
            a.CancelOrder(o).then(function (t) {
              wx.hideLoading();
              var e = getCurrentPages(),
                a = e[e.length - 2],
                o = a.data.params;
              a.setData({ refresh: !0 }),
                (o.page = 1),
                a.getOrderList(o),
                n.showMsg(r.data._t["取消成功"]),
                wx.navigateBack();
            });
        }
      },
    });
  },
  copyText: function (t) {
    var e = t.currentTarget.dataset.text;
    wx.setClipboardData({
      data: e,
      success: function (t) {
        wx.hideLoading(), n.showMsg(that.data._t["复制成功"]);
      },
    });
  },
  expandMore: function () {
    if (!this.data.isShowQr) this.data.code_i, this.data.code_j;
    this.setData({ isShowQr: !this.data.isShowQr });
  },
  CallPhone: function () {
    wx.makePhoneCall({ phoneNumber: wx.getStorageSync("telphoneNumber") });
  },
  openTip: function () {
    this.setData({ is_show: !0 });
  },
  Cancel: function (t) {
    this.setData({ is_show: !1 });
  },
  toPage: function () {
    wx.navigateTo({
      url:
        "plugin-private://wx393d60d93f70599c/pages/Rule/index?orderType=" +
        this.data.content.orderType +
        "&teamType=" +
        this.data.content.teamType,
    });
  },
  onReady: function () {},
  onShow: function () {},
  onHide: function () {},
  onUnload: function () {
    clearInterval(t);
  },
  onPullDownRefresh: function () {},
  onReachBottom: function () {},
});
